using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class LevelManager : MonoBehaviour {

    public static LevelManager Current { get; set; }

    [SerializeField]
    string startLevel = "";

    [SerializeField]
    List<string> levels = new List<string>();

    void OnEnable() {
        if(Current) {
            Destroy(this);
            return;
        }

        Current = this;
        DontDestroyOnLoad(gameObject);
    }

    public void LoadLevel(int index) {
        SceneManager.LoadScene(levels[index], LoadSceneMode.Single);
    }

    public void LoadNextLevel() {
        int index = levels.IndexOf(SceneManager.GetActiveScene().name);

        LoadLevel((index + 1) % SceneManager.sceneCountInBuildSettings);
    }
}